package com.example.reader.sdk;

import android.content.Context;
import android.os.Build;
import android.text.TextUtils;

public abstract class CardReader {
    public abstract void close();

    public abstract void init(IReaderCallback readerCallback);

    public abstract int readId(IReaderCallback readerCallback);


    public static CardReader getInstance(Context context) {

        if (Build.VERSION.SDK_INT == 23 || Build.VERSION.SDK_INT == 21) {
            return new DeviceReaderA(context);
        }
        return new DeviceReaderB(context);
    }

    public String getsexinfo(byte[] bsex) {
        String StrSexInfo = "";
        if (bsex[0] == (byte) 48) {
            return "未知";
        }
        if (bsex[0] == (byte) 49) {
            return "男";
        }
        if (bsex[0] == (byte) 50) {
            return "女";
        }
        if (bsex[0] == (byte) 57) {
            return "未说明";
        }
        return " ";
    }

    /* access modifiers changed from: protected */
    public String getnation(byte[] bNationinfo) {
        String StrNation = "";
        switch ((((bNationinfo[0] - 48) * 10) + bNationinfo[2]) - 48) {
            case 1:
                return "汉";
            case 2:
                return "蒙古";
            case 3:
                return "回";
            case 4:
                return "藏";
            case 5:
                return "维吾尔";
            case 6:
                return "苗";
            case 7:
                return "彝";
            case 8:
                return "壮";
            case 9:
                return "布依";
            case 10:
                return "朝鲜";
            case 11:
                return "满";
            case 12:
                return "侗";
            case 13:
                return "瑶";
            case 14:
                return "白";
            case 15:
                return "土家";
            case 16:
                return "哈尼";
            case 17:
                return "哈萨克";
            case 18:
                return "傣";
            case 19:
                return "黎";
            case 20:
                return "傈僳";
            case 21:
                return "佤";
            case 22:
                return "畲";
            case 23:
                return "高山";
            case 24:
                return "拉祜";
            case 25:
                return "水";
            case 26:
                return "东乡";
            case 27:
                return "纳西";
            case 28:
                return "景颇";
            case 29:
                return "柯尔克孜";
            case 30:
                return "土";
            case 31:
                return "达斡尔";
            case 32:
                return "仫佬";
            case 33:
                return "羌";
            case 34:
                return "布朗";
            case 35:
                return "撒拉";
            case 36:
                return "毛南";
            case 37:
                return "仡佬";
            case 38:
                return "锡伯";
            case 39:
                return "阿昌";
            case 40:
                return "普米";
            case 41:
                return "塔吉克";
            case 42:
                return "怒";
            case 43:
                return "乌孜别克";
            case 44:
                return "俄罗斯";
            case 45:
                return "鄂温克";
            case 46:
                return "德昂";
            case 47:
                return "保安";
            case 48:
                return "裕固";
            case 49:
                return "京";
            case 50:
                return "塔塔尔";
            case 51:
                return "独龙";
            case 52:
                return "鄂伦春";
            case 53:
                return "赫哲";
            case 54:
                return "门巴";
            case 55:
                return "珞巴";
            case 56:
                return "基诺";
            case 57:
                return "其他";
            case 58:
                return "外国血统中国籍人士";
            default:
                return " ";
        }
    }

    /* access modifiers changed from: protected */
    public String format(String primitive) {
        if (TextUtils.isEmpty(primitive)) {
            return "";
        }
        StringBuilder stringBuilder = new StringBuilder();
        int length = primitive.length();
        for (int i = 0; i < length / 2; i++) {
            String number = primitive.substring(i * 2, (i + 1) * 2);
            if (TextUtils.isDigitsOnly(number)) {
                stringBuilder.append((char) Integer.parseInt(number, 16));
            }
        }
        return stringBuilder.toString();
    }

}
